<%@ page 	language="java" 
			contentType="text/html; charset=utf-8"
			pageEncoding="utf-8"
			import="view.PageContent" 
			%>
	
<% 
	String type = "";
	try {
		type = request.getParameter("name");
		
		if (type.equals(null)) {
			type = "index";
		}
	}
	catch (NullPointerException ex) {
		type = "index";
	}
	
	boolean ifHompage = false;
	
	PageContent thispage = new PageContent(type); 
	
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><% out.print(thispage.getTitle()); %></title>

<link rel="stylesheet" type="text/css" href="css/fonts.css">
<link rel="stylesheet" type="text/css" href="css/style.css">

<%	if (thispage.isHomepage()) 
		out.print("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/index.css\">");
	else 
		out.print("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/page.css\">");			
%>
<script  type="text/javascript">
	function call(name) {
		window.location.replace("index.jsp?name="+name);
	}
</script>
</head>

<body>
	<header>
		<section id="topBar">
			<div class="center">
				<div id="logo">
					<div>
						<a href="index.jsp">SO<b>P</b>H</a>
					</div>
					<div>
						<a href="index.jsp">System obsługi <br />przedstawicieli handlowych</a>
					</div>
				</div>
				<nav>
					<ul>
						<% 
							for (String pageName[]:thispage.getHeader().getMenu().getMenuList()) {								
								out.print("<li alt=\"" + pageName[1] + "\" onclick='call(\"" + pageName[1] + "\")'>" + pageName[0] + "</li>"  );								
							}
						%>
					</ul>
				</nav>
			</div>
		</section>

		<section id="slideshow">
			<% 				
					for (String[] imageName : thispage.getHeader().getSlideshow()) {
						
						String imageURL = imageName[0];
						String imageTitle = imageName[1];
						String imageDesc = imageName[2];
						
						out.print("<img src=\"images/slideshow/" + imageURL + "\" alt=\"\" />" +
									"<div id=\"caption\">" +
										"<h2>" + imageTitle + "</h2>" +
										"<h3>" + imageDesc + "</h3>" +
									"</div>");
					}
			%>
		</section>
	</header>

	<% if (thispage.isHomepage()) { %>
	<section id="infoBar">
		<ul class="center">
		
			<% 
					for (String[] strongPoint : thispage.getContent().getStrongPoints()) {
						
						String title = strongPoint[0];
						String desc = strongPoint[1];
						
						out.print("<li><h3>" + title + "</h3><h4>" + desc + "</h4></li>" );						
					}				
			%>
		</ul>
	</section>
	
	<section id="content" class="center">
		<% out.print(thispage.getContent().getContentPanel(type)); %>
	</section>
	<% } // end of homepage content
	else {	%> 
	
	
	<section id="infoBar">
		<div class="center">
			<h2><% out.print(thispage.getContent().getTitle()); %></h2>
			<h3><% out.print(thispage.getContent().getDescription()); %></h3>
		</div>
	</section>
	
	<section id="content" class="center">
		<article><% out.print(thispage.getContent().getContentPanel(type)); %></article>		
		<aside>
			<% for (String[] element : thispage.getContent().getSidebar().getSidebarElements()) {
				
				String title = element[1];
				String desc = element[2];
				
				out.print("<div class=\"single\">" +
								"<h3>" + title + "</h3>" +
								"<p>" + desc + "</p>" +
							"</div>");
			}
				
			%>
		</aside>
	</section>
	
	<% } // end of page content %>
	
	<footer class="center">
		<div><% out.print(thispage.getFooter().getAllRightsReservedText()); %></div>
		<div>
			<ul><% 
							for (String pageName[]:thispage.getHeader().getMenu().getMenuList()) {								
								out.print("<li alt=\"" + pageName[1] + "\" onclick='call(\"" + pageName[1] + "\")'>" + pageName[0] + "</li>"  );								
							}
						%>
			 </ul>
		</div>
	</footer>
</body>
</html>